﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectChange.aspx.cs" Inherits="H2.NET.Web.Pages.SMD.SelectChange" %>


<script type="text/javascript">
    function SelectChangeAjaxDone(json) {
        if ($("#ddl_region").val() == "") {
            alert("请选择区域");
            return false;
        }
        if ($("#ddl_province").val() == "") {
            alert("请选择省份");
            return false;
        }
        if (json[DWZ.keys.statusCode] == DWZ.statusCode.ok) {
            window.open(json.navTabId);
            $.pdialog.closeCurrent();
        } else {
            DWZ.ajaxDone(json);
        }
    }
    /* 根据区域初始化省份 */
    function initProvince(arg) {
        var val = $(arg).val();
        var id = $(arg).attr("id");
        if ($.trim(val)) {
            $.ajax({
                type: 'POST',
                url: '<%=Page.ResolveUrl("~/pages/smd/SelectChange.aspx?action=initProvince")%>',
                data: { ar: val, type: (id == "ddl_province" ? "province" : "city") },
                dataType: "json",
                cache: false,
                success: function (json) {
                    var rst = json.navTabId.split("|");
                    var html = "";
                    for (var i = 0; i < rst.length; i++) {
                        if (rst[i]) {
                            var list = rst[i].split(",");
                            html += "<option value='" + list[0] + "'>" + list[1] + "</option>";
                        }
                    }
                    if (id == "ddl_province") {
                        $("#ddl_cityName").find("option:gt(0)").remove().end().append(html);

                    }
                    else {
                        $("#ddl_province").find("option:gt(0)").remove().end().append(html);
                        $("#ddl_cityName").find("option:gt(0)").remove();
                    }
                }
            });
        }
        else {
            if (id == "ddl_province") {
                $("#ddl_cityName").find("option:gt(0)").remove();

            }
            else {
                $("#ddl_province").find("option:gt(0)").remove();
                $("#ddl_cityName").find("option:gt(0)").remove();
            }
        }
    }
</script>

<div class="pageContent">

    
    <form method="post" action="Pages/Smd/SelectChange.aspx?action=create&taskid=<%=TaskAPI.TaskID%>" class="pageForm required-validate" 
        onsubmit="return validateCallback(this, SelectChangeAjaxDone, '确认要发起吗？');" runat="server">
        
        <asp:hiddenfield ID="AutoBusinessKey" runat="server"></asp:hiddenfield>

        <div class="pageFormContent" layouth="50">
            <table class="formTable">
                <tr>
                    <th style="width:15%;">区域：</th>
                    <td style="width:35%;"><select id="ddl_region" runat="server" onchange="initProvince(this)" class="required"></select></td>
                    <th style="width:15%;">省份：</th>
                    <td style="width:35%;"><select id="ddl_province" runat="server" class="required"></select></td>
                </tr>
            </table>

            <table class="formTable" style="margin-top:5px">
                <tbody id="tb_option" runat="server">
                <tr>
                    <td>
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_ChangeStore" value="ChangeStore" checked="True" />门店信息变更
                        </label></td>
                    <td>
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_ChangeDevice" value="ChangeDevice" />设备主数据变更</label></td>
                    <td>
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_ChangeContract" value="ChangeContract" />合同主数据变更</label></td>
                </tr>
                <tr>
                    <td>
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_BatchStore" value="BatchStore" />批量变更门店主数据</label></td>
                    <td>
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_BatchDevice" value="BatchDevice" />批量变更设备主数据</label></td>
                    <td>
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_Transfer" value="Transfer" style="display: none" />
                            <input type="radio" name="Actions" runat="server" id="r_BatchContract" value="BatchContract" />批量变更合同主数据
                        </label></td>
                </tr>
                <tr >
                    <td colspan="3" style="display:none">
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_DiscardDevice" value="DiscardDevice" />设备报废、库存</label></td>
                    <td style="display:none" colspan="2">
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_ChangeDealer" value="ChangeDealer" />经销商变更</label></td>
                    <td style="display:none">
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_DegradeStore" value="DegradeStore" disabled="disabled" />门店关闭、降级</label></td>
                    <td style="display:none">
                        <label style="width: auto;">
                            <input type="radio" name="Actions" runat="server" id="r_MDCItss" value="MDCItss"/>MDCItss</label></td>
                </tr>
                </tbody>
                <tbody id="tb_autoBusinessKey" runat="server" Visible="False">
                <tr>
                    <td colspan="3">所选流程：<asp:literal ID="l_autoBusinessKey" runat="server"></asp:literal>
                        <p style="color:red;">注：点击“发起流程”按钮之后会生成一条待办任务，并在我的申请中永久显示</p>
                    </td>
                </tr>    
                </tbody>
            </table>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">发起流程</button>
                            </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">关闭窗体</button></div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
